package com.hackerrank.contests.sep13.challenges.sherlockandthebeast;

import java.util.Scanner;

public class Solution {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int T = in.nextInt();
		in.nextLine();
		for(int t = 0; t < T; t++) {
			int N = in.nextInt(), n3 = 0;
			switch(N % 3) {
			case 0:
				n3 = 0;
				break;
			case 1:
				n3 = 10;
				break;
			case 2:
				n3 = 5;
				break;
			}
			if(n3 > N)
				System.out.print(-1);
			else {
				StringBuilder buf = new StringBuilder();
				for(int n = 0; n < N - n3; n++)
					buf.append(5);
				for(int n = 0; n < n3; n++)
					buf.append(3);
				System.out.print(buf);
			}
			System.out.println();
		}
	}
}
